<script>
import { mapState } from 'vuex';

export default {
  data() {
    return {
      isShow: false,
      curItem: {},
    };
  },
  computed: {
    ...mapState({
      others: (state) => state.config.others || [],
    }),
  },
  methods: {
    handleClick(item) {
      this.curItem = item;
      this.isShow = true;
    },
  },
};
</script>

<template>
  <div v-if="others.length" class="dzq-index-section dzq-index-section--lightbg">
    <div class="dzq-index-section__hd">
      <h2 class="dzq-index-section__title"><span>大咖说</span></h2>
    </div>
    <div class="dzq-index-section__bd dzq-others">
      <div class="zdzq-row">
        <div v-for="(item, index) in others" :key="index" class="zdzq-col-6">
          <div class="dzq-others-item" @click="handleClick(item)">
            <div class="dzq-others-header">
              <img :src="item.avatar" alt="avatar" class="dzq-others-avatar" />
              <div class="dzq-others-name">{{ item.name }}</div>
            </div>
            <div class="dzq-others-desc">{{ item.desc }}</div>
          </div>
        </div>
      </div>
    </div>
    <dz-dialog v-model="isShow" :title="curItem.name" :title-img="curItem.avatar">
      {{ curItem.desc }}
    </dz-dialog>
  </div>
</template>

<style lang="scss">
.dzq-others {
  &-item {
    padding: 20px;
    text-align: center;
    font-size: 0;
    cursor: pointer;
  }
  &-header {
    font-size: 0;
  }
  &-avatar {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 50%;
    background-color: #006eff;
  }
  &-name {
    margin: 15px 0;
    font-size: 20px;
    font-weight: bold;
    color: #242d4e;
  }
  &-desc {
    height: 128px;
    font-size: 14px;
    line-height: 32px;
    letter-spacing: 0;
    text-align: justify;
    color: #8b9db6;

    @include text-ellipsis-multi-line(4);
  }
}

@media screen and (max-width: 768px) {
  .dzq-others {
    &-item {
      margin: 15px;
      background-color: #fff;
      box-shadow: 0 3px 7px 0 rgba(0, 110, 255, 0.16);
    }
    &-header {
      margin-bottom: 30px;
      display: flex;
      flex-direction: row;
      align-items: center;
    }
    &-avatar {
      margin-right: 10px;
      width: 80px;
      height: 80px;
    }
    &-name {
      font-size: 16px;
    }
    &-desc {
      font-size: 15px;
    }
  }
}
</style>
